package com.ferry.transport.api.channel;

import com.ferry.serial.api.OutputBuf;

import java.net.SocketAddress;

/**
 * Created by daiyong
 * 封装原始netty channel
 */
public interface WrappedChannel {

	CloseFutureListener CLOSE = new CloseFutureListener();

	/**
	 * channelId
	 */
	String id();

	/**
	 * 连接是否活跃
	 */
	boolean isActive();

	boolean inIoThread();

	/**
	 * channel绑定的地址
	 */
	SocketAddress localAddress();

	/**
	 * channel 连接的远程地址
	 */
	SocketAddress remoteAddress();

	/**
	 * 是否可写
	 */
	boolean isWritable();

	/**
	 * 是否断线重连
	 */
	boolean isMarkedReconnect();

	/**
	 * 自动读取数据
	 */
	boolean isAutoRead();

	void setAutoRead(boolean autoRead);

	WrappedChannel close();

	WrappedChannel close(FutureListener<WrappedChannel> listener);

	WrappedChannel write(Object msg);

	WrappedChannel write(Object msg, FutureListener<WrappedChannel> listener);

	void addTask(Runnable task);


}
